import * as React from 'react'
import {Upload} from 'antd'
export default props=>{
    //图片上传
    const uploadImg = (e) => {
        console.log('图片上传成功',e)
        if(e.file.response){
            //调用Form.item这个父组件给我的onChange
            props.onChange(e.file.response.data.img)
        }
    }

    return(
        <Upload
            name="xxx"
            action="http://localhost:8090/api/v2/upload/img"
            listType="picture-card"
            className="avatar-uploader"
            showUploadList={false}
            // beforeUpload={beforeUpload}
            onChange={uploadImg}
        >
            {
                props.value?
                    <img style={{ width: '100%' }} src={'http://localhost:8888'+props.value} alt="" />:<div>上传</div>
            }
        </Upload>
    )
}